<?php

class Application_Model_DbTable_Clientes extends Zend_Db_Table_Abstract
{

    protected $_name = 'clientes';

	public function getDatosClienteFromEmail($email) {
		$select  = $this->_db->select()
			->from($this->_name)->where('email = ?', $email);
		//print_r($select->__toString());die();
		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function setLastLogin($email) {
		$data = array('ultimo_ingreso'=>date('Y-m-d H:i:s'));
		$where = $this->getAdapter()->quoteInto('email = ?', $email);
		$result = $this->update($data, $where);

		return $result;
	}
	
	public function getClientes() {
		$select  = $this->_db->select()
			->from($this->_name);

		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function getClientesFromId($idCliente) {
		$select  = $this->_db->select()
			->from($this->_name)->where('id_cliente = ?', $idCliente);;

		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function contar() {
		$select  = $this->_db->select()
			->from($this->_name, array('total' => 'count(*)'));

		$result = $this->getAdapter()->fetchAll($select);
		
		return $result[0]['total'];
	}
}

